package com.ivc.trade.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cs.framework.common.util.DateUtils;
import com.cs.framework.jdbc.common.dao.CommonDao;
import com.ivc.trade.dto.base.BuyInfoDto;
import com.ivc.trade.service.BuyInfoService;

/**
 * 进货信息
 * 
 * @author hedongzhou
 * 
 */
@Service("buyInfoService")
public class BuyInfoServiceImpl implements BuyInfoService {

	@Resource
	private CommonDao commonDao;

	/**
	 * 查询进货信息
	 * 
	 * @param stockNo
	 *            进货信息编号
	 * @return
	 */
	public BuyInfoDto get(Long stockNo) {
		return commonDao.getById(BuyInfoDto.class, stockNo);
	}

	/**
	 * 查询进货信息总数
	 * 
	 * @param buyInfoDto
	 * @return
	 */
	public int count(BuyInfoDto buyInfoDto) {
		return commonDao.count("BuyInfo.query", buyInfoDto);
	}

	/**
	 * 查询进货信息列表
	 * 
	 * @param buyInfoDto
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public <T extends BuyInfoDto> List<T> query(T buyInfoDto) {
		return (List<T>) commonDao.selectList("BuyInfo.query", buyInfoDto, buyInfoDto, buyInfoDto.getClass());
	}

	/**
	 * 新增进货信息
	 * 
	 * @param buyInfoDto
	 * @return
	 */
	public BuyInfoDto save(BuyInfoDto buyInfoDto) {
		buyInfoDto.setApplyDate(DateUtils.getCurrentDate());

		return commonDao.save(buyInfoDto);
	}

}
